<template>
  <div>
    <div class="title">周末自驾</div>
    <ul>
      <router-link
          v-for="item of list"
          :key="item.id"
          :to="{
            path:'/article/'+item.toUrl,
            params:{
              articleId:item.toUrl
            }
          }"
          class="item border-bottom" tag="li"
          @click="onSelectArticle(item.toUrl)"
      >
        <!--        :to="'/article/'+item.toUrl"-->
        <div class="item-img-wrapper">
          <img class="item-img" :src="item.imgUrl">
        </div>
        <div class="item-info">
          <p class="item-title">{{ item.title }}</p>
          <p class="item-desc">{{ item.content }}</p>
          <!--          <p class="item-desc">{{ item.toUrl }}</p>-->
        </div>
      </router-link>
    </ul>
  </div>
</template>

<script>
import {onMounted} from "vue";
import store from "@/store";

export default {
  name: 'HomeWeekend',
  props: {list: Array},
  setup() {
    function onSelectArticle(articleId) {
      store.commit('changeArticle', articleId)
    }

    return {
      onSelectArticle
    }
  }
}
</script>

<style scoped lang="stylus">
@import "~styles/vaibles.styl"
@import "~styles/mixins.styl"
.title
  line-height .8rem
  background #eee
  text-indent .2rem

.item-img-wrapper
  overflow: hidden
  height: 0
  padding-bottom: 40.09%

  .item-img
    width: 100%

.item-info
  padding .1rem

  .item-title
    line-height .44rem
    font-size .42rem
    ellipsis()

  .item-desc
    margin-top -.2rem
    line-height .54rem
    font-size .32rem
    color #ccc
    ellipsis()
</style>
